package com.toune.movie.mvp.model;

import com.toune.movie.base.Api;
import com.toune.movie.base.myUtil.NoHttpCallBack;
import com.toune.movie.base.myUtil.RequstUtils;
import com.toune.movie.mvp.contract.LoginContract;
import com.toune.movie.mvp.presenter.LoginPresenter;
import com.toune.movie.vo.LoginVo;
import com.toune.movie.vo.VerifyVo;

/**
 * Created by Administrator on 2018/4/26.
 */

public class LoginModel implements LoginContract.Model {

    private LoginPresenter loginPresenter;

    public LoginModel(LoginPresenter loginPresenter) {
        this.loginPresenter = loginPresenter;
    }

    @Override
    public void getVery(String phone) {
        NoHttpCallBack.params.put("phone",phone);
        RequstUtils.POST("",true, new NoHttpCallBack<VerifyVo>(VerifyVo.class) {

            @Override
            protected void getSucceed(VerifyVo verifyVo) {
                loginPresenter.setVerify(verifyVo);
            }

            @Override
            protected void getFailed(String json) {

            }
        });
    }

    @Override
    public void login(String phone, String code) {

        NoHttpCallBack.params.put("phone",phone);
        NoHttpCallBack.params.put("code", code);
        RequstUtils.POST("", true,new NoHttpCallBack<LoginVo>(LoginVo.class) {

            @Override
            protected void getSucceed(LoginVo verifyVo) {
                loginPresenter.setLogin(verifyVo);
            }

            @Override
            protected void getFailed(String json) {

            }
        });
    }
}
